package cn.wolfcode.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class Notice {

    /** */
    private Long id;

    /** 公告标题*/
    private String title;

    /** 创建人*/
    private Employee createUser;

    /** 创建时间*/
    private Date createTime;

    /** 级别*/
    private int level;

    /** 是否已读*/
    private int readed = 2;

    /** 是否已发布*/
    private Boolean release = false;

    /** 公告内容*/
    private String content;

    public String getLevelDisplay(){
        switch (this.level){
            case 1 : return "紧急";
            case 2 : return "重要";
            case 3 : return "普通";
            default: return "待定";
        }
    }

    public String getReadedDisplay(){
        switch (this.readed){
            case 1 : return "已读";
            case 2 : return "未读";
            default: return "待定";
        }
    }

    public String toJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("level",level);
        map.put("content",content);

        return JSON.toJSONString(map);
    }
}
